
/*
Plots
*/ 

* event study design plots
use "${data_derived}/zip_regression_results.dta", clear

* week 31 not complete --> drop
drop if x ==31 

* only show spec with full controls
foreach var in pct_devices_home l_num_visits_total pct_chg_dist_trvld {
	if "`var'" == "pct_devices_home" {
		local ylabel "-0.005(0.0025)0.005"
		local ytitle "Fraction Devices Home"
	}			
	if "`var'" == "l_num_visits_total" {
		local ylabel "-0.05(0.025)0.05"
		local ytitle "Log(1+Number of POI Visits)"
	}
	if "`var'" == "pct_chg_dist_trvld" {
		local ylabel "-3(1)3"
		local ytitle "% Change Distance Traveled (Relative to Jan.)"
	}
	tw (scatter c_`var'_cov x) ///
		(rcap ci_u_`var'_cov ci_l_`var'_cov x, color(gs8)) ///
		, ytitle("`var'") ///
		legend(off) ylabel("`ylabel'") /// 
		ytitle("`ytitle'") ///
		xtitle("") xlabel(1 "Jan 1-7" 5 "Jan 29-Feb 4" 9 "Feb 26-Mar 3" ///
		13 "Mar 25-31" 17 "Apr 22-28" 21 "May 20-26" 25 "June 17-23" ///
		29 "July 15-21", angle(30))
	graph export "${plots}/event_study_full_controls_`var'.png", replace
}

* compare different types of POIs to all types
foreach var in entertain fd_plces fd_stores health parks retail  {
	if "`var'" == "entertain" 			local type "Entertainment"
	if "`var'" == "fd_plces" 			local type "Food Services + Drinking Places"
	if "`var'" == "fd_stores" 			local type "Food and Beverage Stores"
	if "`var'" == "health" 				local type "Health Care + Social Assist."
	if "`var'" == "parks" 				local type "Parks"
	if "`var'" == "retail" 				local type "Retail Excl. Food + Bev."
	tw (scatter c_l_num_visits_`var'_cov x, color(red)) ///
		(scatter c_l_num_visits_total_cov x, color(gs10)) ///
		(rcap ci_u_l_num_visits_`var'_cov ci_l_l_num_visits_`var'_cov x, color(red)) ///
		(rcap ci_u_l_num_visits_total_cov ci_l_l_num_visits_total_cov x, color(gs10)) ///
		, ytitle("Log(1+Number of POI Visits)") ylabel("-0.075(0.025)0.05", gmin gmax) ///
		legend(order(1 "`type'" 2 "All POI Types") pos(8) col(1)) /// 
		xtitle("") xlabel(1 "Jan 1-7" 5 "Jan 29-Feb 4" 9 "Feb 26-Mar 3" ///
		13 "Mar 25-31" 17 "Apr 22-28" 21 "May 20-26" 25 "June 17-23" ///
		29 "July 15-21", angle(30))
	graph export "${plots}/event_study_l_num_visits_`var'.png", replace
}

* make a table with summary stats for high and low exposure places
use "${data_derived}/zip_regression_data.dta", clear

keep if week ==1 & year ==2020

label def high_exp 0 "Low Exposure" 1 "High Exposure"
label val high_exp high_exp
label var men "Fraction Male"
label var white "Fraction White"
label var black "Fraction Black"
label var asian "Fraction Asian"
label var med_hh_inc "Median HH Inc."
label var total_mngmt_bus_sci_arts "Management + Business + Science + Arts"
label var total_service_occ "Service Occupations"
label var total_prod_trans "Production + Transportation"
label var total_age_below_18 "Fraction Age <18"
label var total_age_18_24 "Fraction Age 18-24"
label var total_age_25_34 "Fraction Age 25-34"
label var total_age_35_44 "Fraction Age 35-44"
label var total_age_45_54 "Fraction Age 45-54"
label var total_age_55_64 "Fraction Age 55-64"
label var total_age_65_74 "Fraction Age 65-74"
label var total_age_75_and_above "Fraction Age >= 75"
label var hs_ged "Fraction High School / GED"
label var some_coll "Fraction Some College"
label var coll "Fraction College Degree"
label var pop_density "Population Density"
label var frac_broadband "Fraction High-Speed Internet"
label var pop "Population"
label var number_poi_total "Mean Number of POIs"
label var number_poi_entertain "POIs: Arts, Entertainment, Recreation"
label var number_poi_fd_plces "POIs: Food Services + Drinking Places"
label var number_poi_fd_stores "POIs: Food and Beverage Stores"
label var number_poi_health "POIs: Health Care + Social Assist."
label var number_poi_parks "POIs: Parks"
label var number_poi_retail "POIs: Retail Excl. Food + Bev."

replace pop_density = pop_density * 1000000

local balvars_all men white black asian med_hh_inc total_mngmt_bus_sci_arts total_service_occ total_prod_trans total_age_below_18 total_age_18_24 total_age_25_34 total_age_35_44 total_age_45_54 total_age_55_64 total_age_65_74 total_age_75_and_above hs_ged some_coll coll pop_density frac_broadband pop number_poi_total

eststo clear
sort high_exp
by high_exp : eststo: quietly estpost summarize `balvars_all' [w=pop], listwise
esttab using "${tables}/sum_stats.csv", ///
	label nodepvar replace cells("mean(fmt(%9.2f)) sd(star fmt(%9.2f))")

eststo clear
esttab using "${tables}/sum_stats.tex", ///
	label nodepvar replace cells("mean(fmt(%9.3f)) sd(star par fmt(%9.3f))")
